package(
    default_visibility = ["//visibility:public"],
)

licenses(["notice"])  # Apache 2.0

exports_files(["LICENSE"])

# Data for core MIME/Unix/Windows encodings:
# ISO 8859-2..9, 15; Windows-125x; EUC-CN; GBK (Windows cp936); GB 18030;
# Big5 (Windows cp950); SJIS (Windows cp932); EUC-JP; EUC-KR, KS C 5601;
# Windows cp949. Data is pre-processed for little-endian platforms. To replicate
# this pre-processing (if you want additional encodings, for example), do the
# following:
#
# First, download, build, and install ICU. This installs tools such as makeconv.
# Then, run the following from your icu4c/source directory:
#   $ cp [path to filters.json] .
#   $ ICU_DATA_FILTER_FILE=filters.json ./runConfigureICU Linux
#   $ make clean && make
#   $ cd data/out/tmp
#   $ genccode icudt70l.dat   # Note: this number must match version, and below too!
#   $ echo 'U_CAPI const void * U_EXPORT2 uprv_getICUData_conversion() { return icudt70l_dat.bytes; }' >> icudt70l_dat.c
#
# This creates icudt70l_dat.c, which you can move, rename, gzip, then split,
# for example (but you can change to other numbers):
#   $ cp icudt70l_dat.c icu_conversion_data.c
#   $ gzip icu_conversion_data.c
#   # Note: make sure you don't forget the last . below!
#   $ split -a 3 -b 100000 icu_conversion_data.c.gz icu_conversion_data.c.gz.
#
# Then, copy the generated files to this directory, removing existing ones.
#
# The current files have been generated by this filter (in filters.json):
# {
#   "localeFilter": {
#     "filterType": "language",
#     "includelist": [
#       "en"
#     ]
#   }
# }
# Please make sure to keep this updated if you change the data files.
filegroup(
    name = "conversion_files",
    srcs = glob(["icu_conversion_data.c.gz.*"]),
)

# Data files are compressed and split to work around git performance degradation
# around large files.
genrule(
    name = "merge_conversion_data",
    srcs = [":conversion_files"],
    outs = ["conversion_data.c"],
    cmd = "cat $(locations :conversion_files) | gunzip > $@",
)

cc_library(
    name = "conversion_data",
    srcs = [":conversion_data.c"],
    deps = ["@icu//:headers"],
    alwayslink = 1,
)
